/****************************************
Header name: main.c
Author: Gu Zhengxiong
Version: 2013.11.21
Description:The file works.
****************************************/

#include <stdlib.h>
#include <stdio.h>

# include "StudentInfo.h"
# include "StudentGrade.h"
# include "Student.h"
# include "Manip.h"

PINFO
ReadInfo (void);
PGRADE
ReadGrade (void);
int
main (void)
{
	PMANIP wangluo2 = ManipInitialize ();
	PSTUDENT phead = wangluo2->Construct ();
	wangluo2->Add (phead, ReadInfo (), ReadGrade ());
	putchar ('\n');
	wangluo2->Add (phead, ReadInfo (), ReadGrade ());
	wangluo2->DisplayInfo (phead);
	wangluo2->DisplayGrade (phead);
	wangluo2->Destroy (phead);

	free (phead);
	free (wangluo2);

	return EXIT_SUCCESS;
}

PINFO
ReadInfo (void)
{
	PINFO pi = (PINFO)malloc (sizeof (INFO));
	printf ("Enter a number (under 16 bits): ");
	scanf ("%s", pi->number);
	printf ("Enter a name (under 32 chars):");
	scanf ("%s", pi->name);
	printf ("Enter an address (under 256 chars):");
	scanf ("%s", pi->address);
	printf ("Enter an age: ");
	scanf ("%d", &(pi->age));
	return pi;
}
PGRADE
ReadGrade (void)
{
	PGRADE pg = (PGRADE)malloc (sizeof (GRADE));
	printf ("Enter maths scores:");
	scanf ("%d", &(pg->maths));
	printf ("Enter clang scores:");
	scanf ("%d", &(pg->clang));
	printf ("Enter english scores:");
	scanf ("%d", &(pg->english));
	return pg;
}
/**********Test 1 Start
Enter maths scores:100
Enter clang scores:98
Enter english scores:99
Enter a number (under 16 bits): 201358080225
Enter a name (under 32 chars):GuZhengxiong
Enter an address (under 256 chars):Hunan
Enter an age: 20

Enter maths scores:98
Enter clang scores:97
Enter english scores:100
Enter a number (under 16 bits): 201458080225
Enter a name (under 32 chars):ZhangHang
Enter an address (under 256 chars):Hunan
Enter an age: 18
201358080225 GuZhengxiong Hunan 20 100 98 99
201458080225 ZhangHang Hunan 18 98 97 100
Press any key to continue
Test 1 End**********/